From 1033d025c45050c7e6fe77a9c7eb7572d13b270d Mon Sep 17 00:00:00 2001 From: "emellor@leeni.uk.xensource.com" Date: Tue, 25 Oct 2005 11:22:47 +0100 Subject: [PATCH] Moved SuSE-specific getcfg call into a preiftransfer call. The semantics of this aren't beautiful, but this gets the distro-specific code out of the body of the network-bridge script and into a common place, while still preserving the existing code behaviour. Signed-off-by: Ewan Mellor --- tools/examples/network-bridge | 4 +-- tools/examples/xen-network-common.sh | 38 ++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/tools/examples/network-bridge b/tools/examples/network-bridge index c9d00b8e81..e9a75ea749 100755 --- a/tools/examples/network-bridge +++ b/tools/examples/network-bridge @@ -208,7 +208,7 @@ op_start () { if ip link show ${vdev} 2>/dev/null >/dev/null; then mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'` - eval `/sbin/getcfg -d /etc/sysconfig/network/ -f ifcfg- -- ${netdev}` + preiftransfer ${netdev} transfer_addrs ${netdev} ${vdev} if ! ifdown ${netdev}; then # if ifup didn't work, see if we have an ip= on cmd line @@ -231,7 +231,7 @@ op_start () { ip link set ${bridge} up ip link set ${vif0} up ip link set ${pdev} up - if ! ifup ${HWD_CONFIG_0} ${netdev} ; then + if ! ifup ${netdev} ; then if [ ${kip} ] ; then # use the addresses we grocked from /proc/cmdline if [ -z "${kmask}" ]; then diff --git a/tools/examples/xen-network-common.sh b/tools/examples/xen-network-common.sh index d4af3990ca..c2fc311fac 100644 --- a/tools/examples/xen-network-common.sh +++ b/tools/examples/xen-network-common.sh @@ -16,11 +16,40 @@ # -# Gentoo doesn't have ifup/ifdown: define appropriate alternatives -if ! which ifup >&/dev/null +# On SuSE it is necessary to run a command before transfering addresses and +# routes from the physical interface to the virtual. This command creates a +# variable $HWD_CONFIG_0 that specifies the appropriate configuration for +# ifup. + +# Gentoo doesn't have ifup/ifdown, so we define appropriate alternatives. + +# Other platforms just use ifup / ifdown directly. + +## +# preiftransfer +# +# @param $1 The current name for the physical device, which is also the name +# that the virtual device will take once the physical device has +# been renamed. + +if [ -e /etc/SuSE-release ] +then + preiftransfer() + { + eval `/sbin/getcfg -d /etc/sysconfig/network/ -f ifcfg- -- $1` + } + ifup() + { + /sbin/ifup ${HWD_CONFIG_0} $1 + } +elif ! which ifup >&/dev/null then if [ -e /etc/conf.d/net ] then + preiftransfer() + { + true + } ifup() { /etc/init.d/net.$1 start @@ -34,4 +63,9 @@ then "You don't have ifup and don't seem to be running Gentoo either!" exit 1 fi +else + preiftransfer() + { + true + } fi -- 2.30.2